package com.linkoog.devtools.http.request.http_response;

import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.util.ui.JBUI;
import com.linkoog.devtools.http.request.common.HttpResponse;
import com.linkoog.devtools.http.request.http_response.response.ResponsePanel;
import com.linkoog.devtools.http.request.http_response.response_status.ResponseStatusPanel;

import javax.swing.*;
import java.awt.*;

public class HttpServiceTestResponsePanel extends JPanel implements Disposable {

    private Project project;

    private ResponseStatusPanel responseStatusPanel;
    private ResponsePanel responsePanel;

    public HttpServiceTestResponsePanel(Project project) {
        super(new BorderLayout());
        this.project = project;
        this.setBorder(JBUI.Borders.customLineLeft(new JBColor(Gray._214, new Color(30, 31, 34))));

        responseStatusPanel = new ResponseStatusPanel();
        responseStatusPanel.setBorder(JBUI.Borders.customLineBottom(new JBColor(Gray._214, new Color(30, 31, 34))));
        Disposer.register(this, responseStatusPanel);
        add(responseStatusPanel, BorderLayout.NORTH);

        responsePanel = new ResponsePanel(project);
        Disposer.register(this, responsePanel);
        add(responsePanel, BorderLayout.CENTER);
    }

    public void reset(HttpResponse httpResponse) {
        responseStatusPanel.reset(httpResponse.getStatus(), httpResponse.getCostTime(), httpResponse.getSize());
        responsePanel.reset(httpResponse);
    }


    @Override
    public void dispose() {
    }
}
